/*=
 * @Date: 2020-02-28 16:28:32 
 * 角色表
 */
const mongoose = require('mongoose')

const { Schema } = mongoose


const RoleSchema = new Schema({
                                                              
    name: { type: String},       //名称     
    disable: {type: Number, enum: [1, 2], default: 1, required: true},//状态 1：有效 2：无效
    create_at: { type: Date, default: Date.now, index: -1,select: true },
    update_at: { type: Date, default: Date.now ,select: true},
})


RoleSchema.pre('save', function (next) {
    let now = new Date()
    this.update_at = now;
    next()
})




mongoose.model('role', RoleSchema)
module.exports = RoleSchema

